package main

import (
	"fmt"
)

type USB interface {
	Name() string
	// SetName(name string)
	Connect()
}

type Connecter interface {
	Connect()
}

type IPhone struct {
	imap map[int]string
	name string
}

func (pc IPhone) Name() string {
	return pc.name
}

func (pc *IPhone) SetName(name string) {
	pc.name = name
}

func (pc IPhone) Connect() {
	fmt.Println("Connected:", pc.name, pc.imap)
}

func main() {
	pc := IPhone{name: "Iphone"}
	pc.imap = map[int]string{1: "a", 2: "b", 3: "c"}
	var a USB
	a = USB(pc)
	pc.imap[1] = "1111"
	// pc.name = "usb"
	pc.SetName("usb")
	a.Connect()
	DisConnect(a)
	fmt.Println("pc")
	pc.Connect()
	DisConnect(pc)
}

func DisConnect2(usb USB) {
	fmt.Println("DisConnected:", usb.Name())
}

func DisConnect(usb interface{}) {
	// fmt.Println("DisConnected:", usb.Name())
	switch v := usb.(type) {
	case IPhone:
		fmt.Println("DissConnected:", v.name)
	default:
		fmt.Println("Unknown device")
	}
}
